🎖️GitЯра🎖️
Commit b5dd6ff9e9b05e2276517599c5b1a6d79bb1a046
Parents : 5104867
Author : James Rich <james.a.rich@gmail.com>
Date : 2026-06-12T06:43:09-05:00
fix(di): start AppFunctionStateSync from the Application, not createdAtStart
The google-flavor AppFunctionsModule registered AppFunctionStateSync
with createdAtStart = true. Eager creation needs the androidContext
binding and immediately spawns the prefs-observing sync coroutine —
so any Koin graph built outside a running app failed with
NoDefinitionFoundException for android.content.Context. That broke
KoinVerificationTest.verifyTypedBootstrapLoadsModuleGraph (the typed
koinApplication<AndroidKoinApp>() bootstrap instantiates eager
singletons), failing the shard-app CI job on this branch.
The definition is now a plain @Single (the graph stays lazily
constructible) and GoogleMeshUtilApplication.onCreate resolves it once
after startKoin has bound androidContext — same production behavior,
explicit instead of implicit. It was the repo's only createdAtStart.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: James Rich <james.a.rich@gmail.com>
Changes
2 files changed, 14 insertions(+), 1 deletions(-)
Diff
diff --git a/androidApp/src/google/kotlin/org/meshtastic/app/GoogleMeshUtilApplication.kt b/androidApp/src/google/kotlin/org/meshtastic/app/GoogleMeshUtilApplication.kt
index 9e9970235f..b3eaef2103 100644
--- a/androidApp/src/google/kotlin/org/meshtastic/app/GoogleMeshUtilApplication.kt
+++ b/androidApp/src/google/kotlin/org/meshtastic/app/GoogleMeshUtilApplication.kt
@@ -18,6 +18,7 @@ package org.meshtastic.app
import androidx.appfunctions.service.AppFunctionConfiguration
import org.koin.java.KoinJavaComponent.getKoin
+import org.meshtastic.app.ai.appfunctions.AppFunctionStateSync
import org.meshtastic.app.ai.appfunctions.MeshtasticAppFunctions
/**
@@ -30,6 +31,14 @@ class GoogleMeshUtilApplication :
MeshUtilApplication(),
AppFunctionConfiguration.Provider {
+ override fun onCreate() {
+ super.onCreate()
+ // Start the AppFunctions enabled-state sync. Resolved here (after startKoin has bound
+ // androidContext) rather than via createdAtStart so that Koin graphs built outside a
+ // running app — verification tests, previews — stay lazily constructible.
+ getKoin().get<AppFunctionStateSync>()
+ }
+
override val appFunctionConfiguration: AppFunctionConfiguration
get() =
AppFunctionConfiguration.Builder()
diff --git a/androidApp/src/google/kotlin/org/meshtastic/app/di/AppFunctionsModule.kt b/androidApp/src/google/kotlin/org/meshtastic/app/di/AppFunctionsModule.kt
index c632f14882..a2a8659ef7 100644
--- a/androidApp/src/google/kotlin/org/meshtastic/app/di/AppFunctionsModule.kt
+++ b/androidApp/src/google/kotlin/org/meshtastic/app/di/AppFunctionsModule.kt
@@ -32,7 +32,11 @@ class AppFunctionsModule {
@Single
fun meshtasticAppFunctions(provider: AiFunctionProvider): MeshtasticAppFunctions = MeshtasticAppFunctions(provider)
- @Single(createdAtStart = true)
+ // NOT createdAtStart: eager creation needs the androidContext binding and spawns the sync
+ // coroutine, which breaks (and is wrong for) any Koin graph built outside a running app —
+ // e.g. KoinVerificationTest's typed-bootstrap check. GoogleMeshUtilApplication starts it
+ // explicitly at app startup instead.
+ @Single
fun appFunctionStateSync(
context: Context,
prefs: AppFunctionsPrefs,
Served by rngit 1.5.0 - Generated in 0.07s